// pages/introduce/introduce.js
var app = getApp();
const getPageInfoUrl = '/GlobalConfig/getAppDesc';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isLoading: 1,//是否显示加载中图标
    app_desc_configs:[]//存储介绍列表
  },
  // 获取页面信息
  getPageInfo:function(){
    var _this = this;
    var requestData = {
      token: _this.data.token,
      version: app.setConfig.version,
      type: app.setConfig.type
    }
    app.post(getPageInfoUrl, requestData, function (res) {
      if(res.code==2000){
      var configs = wx.getStorageSync('configs');
      for (var i = 0; i < res.data.app_desc_configs.length; i++) {
        for (var j = 0; j < res.data.app_desc_configs[i].image.length;j++){
          res.data.app_desc_configs[i].image[j] = configs.static_url_http + '/' + res.data.app_desc_configs[i].image[j];
        }
        
      }
      _this.setData({
        isLoading:0,
        app_desc_configs: res.data.app_desc_configs
      })
      }else{
        wx.showToast({
          title: res.msg,
          icon: "none",
          duration: 2000
        });
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  this.loop();
  },
  // 判断是否获取到token的值了
  loop: function () {
    var _this = this;
    var theToken = wx.getStorageSync("token");
    if (!theToken) {
      setTimeout(function () { _this.loop() }, 100);
    } else {
      _this.setData({
        token: theToken
      });
      _this.getPageInfo();
    }
  }
})